package com.hy.controller;

import com.hy.service.DeptfundsService;
import com.hy.service.impl.DeptfundsServiceImpl;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * (Classify)表控制层
 *
 * @author makejava
 * @since 2024-04-29 11:08:28
 */
@RestController
@RequestMapping("deptfunds")
public class DeptfundsController {
    /**
     * 服务对象
     */

    private DeptfundsService deptfundsService = new DeptfundsServiceImpl();

    @RequestMapping("select")
    public ResponseEntity<List<Map<String,Object>>> queryAll(String deptName) throws Exception {
        return ResponseEntity.ok(this.deptfundsService.queryAll(deptName));
    }

    @RequestMapping("selectDeptAll")
    public ResponseEntity<List<Map<String,Object>>> queryDeptAll(Integer deptId) throws Exception {
        return ResponseEntity.ok(this.deptfundsService.selectDeptAll(deptId));
    }

    /**
     * 编辑数据
     *
     * @return 编辑结果
     */
    @RequestMapping("update")
    public ResponseEntity<Boolean> edit(Integer DEPT_ID ,Double balance) throws Exception {
        return ResponseEntity.ok(this.deptfundsService.updateDeptBalanceAdd(DEPT_ID,balance));
    }

    /**
     * 删除数据
     *
     * @param deptId 主键
     * @return 删除是否成功
     */
    @RequestMapping("delete")
    public ResponseEntity<Boolean> deleteById(int deptId) throws Exception {
        return ResponseEntity.ok(this.deptfundsService.deleteById(deptId));
    }

}

